home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Activation / SubWindowFocus.cp < prev    next >
Text File  |  1997-06-28  |  3KB  |  150 lines

  1. // SubWindowFocus.cp
  2.  
  3. #ifndef SubWindowFocus_h
  4. #include "SubWindowFocus.h"
  5. #endif
  6.  
  7. SubWindowFocus::SubWindowFocus( WindowFocus& window, AtStart )
  8.   : Enableable( true ),
  9.      link( this ),
  10.      siblings( window.subFoci ),
  11.      tabber( window, *this )
  12.   {
  13.     window.subFoci.Add( link, beforeStart );
  14.   }
  15.  
  16. SubWindowFocus::SubWindowFocus( WindowFocus& window, AtEnd )
  17.   : Enableable( true ),
  18.      link( this ),
  19.      siblings( window.subFoci ),
  20.      tabber( window, *this )
  21.   {
  22.     window.subFoci.Add( link, afterEnd );
  23.   }
  24.  
  25. SubWindowFocus::SubWindowFocus( WindowFocus& window,
  26.                                           Before,
  27.                                           SubWindowFocus& sibling )
  28.   : Enableable( true ),
  29.      link( this ),
  30.      siblings( window.subFoci ),
  31.      tabber( window, *this )
  32.   {
  33.     window.subFoci.Add( link, before, sibling.link );
  34.   }
  35.  
  36. SubWindowFocus::SubWindowFocus( WindowFocus& window,
  37.                                           After,
  38.                                           SubWindowFocus& sibling )
  39.   : Enableable( true ),
  40.      link( this ),
  41.      siblings( window.subFoci ),
  42.      tabber( window, *this )
  43.   {
  44.     window.subFoci.Add( link, after, sibling.link );
  45.   }
  46.  
  47. SubWindowFocus::SubWindowFocus( WindowFocus& window,
  48.                                           TabKeys& tabHandler,
  49.                                           AtStart )
  50.   : Enableable( true ),
  51.      link( this ),
  52.      siblings( window.subFoci ),
  53.      tabber( window, tabHandler )
  54.   {
  55.     window.subFoci.Add( link, beforeStart );
  56.   }
  57.  
  58. SubWindowFocus::SubWindowFocus( WindowFocus& window,
  59.                                           TabKeys& tabHandler,
  60.                                           AtEnd )
  61.   : Enableable( true ),
  62.      link( this ),
  63.      siblings( window.subFoci ),
  64.      tabber( window, tabHandler )
  65.   {
  66.     window.subFoci.Add( link, afterEnd );
  67.   }
  68.  
  69. SubWindowFocus::SubWindowFocus( WindowFocus& window,
  70.                                           TabKeys& tabHandler,
  71.                                           Before,
  72.                                           SubWindowFocus& sibling )
  73.   : Enableable( true ),
  74.      link( this ),
  75.      siblings( window.subFoci ),
  76.      tabber( window, tabHandler )
  77.   {
  78.     window.subFoci.Add( link, before, sibling.link );
  79.   }
  80.  
  81. SubWindowFocus::SubWindowFocus( WindowFocus& window,
  82.                                           TabKeys& tabHandler,
  83.                                           After,
  84.                                           SubWindowFocus& sibling )
  85.   : Enableable( true ),
  86.      link( this ),
  87.      siblings( window.subFoci ),
  88.      tabber( window, tabHandler )
  89.   {
  90.     window.subFoci.Add( link, after, sibling.link );
  91.   }
  92.  
  93. void SubWindowFocus::TabForward()
  94.   {
  95.     for ( const ListLink<SubWindowFocus> *p = link.Next();
  96.             p != 0;
  97.             p = p->Next() )
  98.         if ( (*p)->Enabled() )
  99.           {
  100.             Parent()->FavorChild( **p );
  101.             return;
  102.           }
  103.     
  104.     for ( const ListLink<SubWindowFocus> *p = siblings.First();
  105.             p != &link;
  106.             p = p->Next() )
  107.         if ( (*p)->Enabled() )
  108.           {
  109.             Parent()->FavorChild( **p );
  110.             return;
  111.           }
  112.   }
  113.  
  114. void SubWindowFocus::TabBackward()
  115.   {
  116.     for ( const ListLink<SubWindowFocus> *p = link.Previous();
  117.             p != 0;
  118.             p = p->Previous() )
  119.         if ( (*p)->Enabled() )
  120.           {
  121.             Parent()->FavorChild( **p );
  122.             return;
  123.           }
  124.     
  125.     for ( const ListLink<SubWindowFocus> *p = siblings.Last();
  126.             p != &link;
  127.             p = p->Previous() )
  128.         if ( (*p)->Enabled() )
  129.           {
  130.             Parent()->FavorChild( **p );
  131.             return;
  132.           }
  133.   }
  134.  
  135. void SubWindowFocus::BeEnabled()
  136.   {
  137.     if ( Parent()->FavoredChild() == 0 )
  138.         Parent()->FavorChild( *this );
  139.   }
  140.  
  141. void SubWindowFocus::BeDisabled()
  142.   {
  143.     if ( Parent()->FavoredChild() == this )
  144.       {
  145.         TabForward();
  146.         if ( Parent()->FavoredChild() == this )
  147.             Parent()->FavorNoChild();
  148.       }
  149.   }
  150.